package com.atguigu.gmall.activity.service.impl;

import com.atguigu.gmall.activity.service.SeckillGoodsService;
import com.atguigu.gmall.common.constant.RedisConst;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 秒杀
 */
@Service
public class SeckillServiceImpl implements SeckillGoodsService {

    //从缓存中查询
     @Autowired
     private RedisTemplate redisTemplate;

     //列表数据
    @Override
    public List<SeckillGoods> list() {
        return redisTemplate.opsForHash().values(RedisConst.SECKILL_GOODS);
    }

    //详情数据
    @Override
    public SeckillGoods seckillDetail(String skuId) {
        return (SeckillGoods) redisTemplate.opsForHash().get(RedisConst.SECKILL_GOODS,skuId);
    }
}
